//
//  PersonalMessageViewController.m
//  1gene
//
//  Created by 1jiyin on 16/3/22.
//  Copyright © 2016年 1jiyin. All rights reserved.
//
//***********个人资料***********
#import "PersonalMessageViewController.h"

@interface PersonalMessageViewController ()
@property(nonatomic,copy)NSArray *biaoqianArray;
/**
 *scrollView
 */
@property(nonatomic,copy)UIScrollView *myScrollView;
/**
 *biaoqianLabName
 */
@property(nonatomic,copy)UILabel *biaoqianLabName;
/**
 *biaoqianImageView
 */
@property(nonatomic,copy)UIImageView *biaoqianImageView;

/**
 *昵称
 */
@property(nonatomic,copy)UILabel *name;
/**
 *个性签名
 */
@property(nonatomic,copy)UILabel *personalName;
/**
 *城市
 */
@property(nonatomic,copy)UILabel *cityLab;
/**
 *行业
 */
@property(nonatomic,copy)UILabel *businessLab;
/**
 *性别女
 */
@property(nonatomic,copy)UIImageView *womanImageView;
/**
 *年龄
 */
@property(nonatomic,copy)UILabel *ageLab;
/**
 *手机号码
 */
@property(nonatomic,copy)UILabel *telephoneLab;
/**
 *性别男
 */
@property(nonatomic,copy)UIImageView *manImageView;
/*
 *个人信息完整度 0% 15% 30% 50% 70% 90% 100%
 */
@property(nonatomic,assign)NSInteger personalMessageState;

@property(nonatomic,copy)PersonalMessageModel *model;

@property(nonnull,copy)NSArray *systemArray;
@end

@implementation PersonalMessageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:[UIView new]];
    [self createNavigation];
    [self getUserInfo];
    // Do any additional setup after loading the view.
}
-(void)createNavigation
{
    self.navigationController.navigationBar.hidden=NO;
    self.navigationController.navigationBar.barTintColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1];
    //返回
    UIButton *leftBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    leftBtn.frame=CGRectMake(0, 0, 25, 25);
    [leftBtn setBackgroundImage:[UIImage imageNamed:@"left_back"] forState:UIControlStateNormal];
    [leftBtn addTarget:self action:@selector(leftBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:leftBtn];
    
    //标题
    UILabel *title=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 44)];
    title.text=@"个人资料";
    title.font=[UIFont systemFontOfSize:22];
    title.textAlignment=NSTextAlignmentCenter;
    title.textColor=[UIColor whiteColor];
    self.navigationItem.titleView=title;
}

#pragma mark 返回上一页
-(void)leftBtnClick:(UIButton *)sender
{
    self.tabBarController.tabBar.hidden=NO;
    self.navigationController.navigationBar.hidden=YES;
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)initData
{
    
    _userModel=[[UserModel alloc]initWithDictionary:_dataDic];
    _biaoqianArray=[NSArray arrayWithArray:_userModel.tags];
    _model=[[PersonalMessageModel alloc]init];
    
    [self calculatenumber];
    
    
}
-(void)createUI
{
     self.navigationController.navigationBar.hidden=YES;
    //返回
    UIButton *leftBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    leftBtn.frame=CGRectMake(0, 0, 25, 25);
    [leftBtn setBackgroundImage:[UIImage imageNamed:@"left_back"] forState:UIControlStateNormal];
    [leftBtn addTarget:self action:@selector(leftBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:leftBtn];
    
    UIScrollView *scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    UIView *headerView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 140)];
    headerView.backgroundColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1];
    [scrollView addSubview:headerView];
    _myScrollView=scrollView;
    
    
    //返回上一页
    UIButton *backBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    backBtn.frame=CGRectMake(10, 20+(44-25)/2.0, 25, 25);
    [backBtn setBackgroundImage:[UIImage imageNamed:@"left_back"] forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(backBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [headerView addSubview:backBtn];
    
    
    
    //个人资料
    UILabel *personalMessageLab=[[UILabel alloc]initWithFrame:CGRectMake(0, 20, self.view.frame.size.width, 44)];
    personalMessageLab.text=@"个人资料";
    personalMessageLab.textColor=[UIColor whiteColor];
    personalMessageLab.font=[UIFont systemFontOfSize:22];
    personalMessageLab.textAlignment=NSTextAlignmentCenter;
    [headerView addSubview:personalMessageLab];
    
    //用户头像
    UIImageView *userHeadImageView=[[UIImageView alloc]initWithFrame:CGRectMake(10, 64, 60, 60)];
    userHeadImageView.image=[UIImage imageNamed:@"155x155-1"];
  //  [userHeadImageView setImageWithURL:[NSURL URLWithString:_userModel.user_profile[@"avatar_url"]] placeholderImage:[UIImage imageNamed:@"155x155-1"]];
    [userHeadImageView sd_setImageWithURL:[NSURL URLWithString:_userModel.user_profile[@"avatar_url"]] placeholderImage:[UIImage imageNamed:@"155x155-1"]];
    userHeadImageView.backgroundColor = [UIColor lightGrayColor];
    userHeadImageView.layer.cornerRadius=60/2.0;
    userHeadImageView.layer.masksToBounds=YES;
    [headerView addSubview:userHeadImageView];
    
    NSData *data=[NSData dataWithContentsOfURL:[NSURL URLWithString:_userModel.user_profile[@"avatar_url"]]];
    UIImage *myHeadImage=[UIImage imageWithData:data];
    userHeadImageView.image=myHeadImage;
    
    
    
    
    
    //昵称
    UILabel *name=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(userHeadImageView.frame)+5, userHeadImageView.frame.origin.y, self.view.frame.size.width-(CGRectGetMaxX(userHeadImageView.frame)+5), userHeadImageView.frame.size.height/2.0)];
    name.text=[NSString stringWithFormat:@"昵称:%@",_userModel.userName];
    name.textColor=[UIColor whiteColor];
    name.font=[UIFont systemFontOfSize:15];
    [headerView addSubview:name];
    
    //个性签名
    UILabel *personalName=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(userHeadImageView.frame)+5, CGRectGetMaxY(name.frame), self.view.frame.size.width-(CGRectGetMaxX(userHeadImageView.frame)+5), userHeadImageView.frame.size.height/2.0)];
    personalName.text=[NSString stringWithFormat:@"个性签名:%@",_userModel.user_profile[@"signatures"]];
    personalName.textColor=[UIColor whiteColor];
    personalName.font=[UIFont systemFontOfSize:15];
    [headerView addSubview:personalName];
    
    //CGFloat lab_h=40;
    //城市
    UIImageView *cityImageView=[[UIImageView alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(headerView.frame)+10, 30, 30)];
    cityImageView.image=[UIImage imageNamed:@"my_city"];
    [scrollView addSubview:cityImageView];
    
    UILabel *cityLabName=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(cityImageView.frame)+5, cityImageView.frame.origin.y, 51, 30)];
    cityLabName.text=@"城 市:";
    cityLabName.textColor=[UIColor grayColor];
    cityLabName.font=[UIFont systemFontOfSize:17];
    [scrollView addSubview:cityLabName];
    
    UILabel *cityLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(cityLabName.frame)+5, cityImageView.frame.origin.y, self.view.frame.size.width-(CGRectGetMaxX(cityLabName.frame)+5), 30)];
    cityLab.text=[NSString stringWithFormat:@"%@%@",_userModel.user_profile[@"province"],_userModel.user_profile[@"city"]];
    cityLab.textColor=[UIColor grayColor];
    cityLab.font=[UIFont systemFontOfSize:15];
    [scrollView addSubview:cityLab];
    
    //划线
    UIView *line1=[[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(cityLab.frame)+10, self.view.frame.size.width, 0.5)];
    line1.backgroundColor=[UIColor colorWithRed:235/255.0 green:235/255.0 blue:241/255.0 alpha:1];
    [scrollView addSubview:line1];
    
    //行业
    UIImageView *businessImageView=[[UIImageView alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(line1.frame)+10, 30, 30)];
    businessImageView.image=[UIImage imageNamed:@"my_job"];
    [scrollView addSubview:businessImageView];
    
    UILabel *businessLabName=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(businessImageView.frame)+5, businessImageView.frame.origin.y, 51, 30)];
    businessLabName.text=@"行 业:";
    businessLabName.textColor=[UIColor grayColor];
    businessLabName.font=[UIFont systemFontOfSize:17];
    [scrollView addSubview:businessLabName];
    
    UILabel *businessLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(businessLabName.frame)+5, businessImageView.frame.origin.y, self.view.frame.size.width-(CGRectGetMaxX(businessLabName.frame)+5), 30)];
    businessLab.text=_userModel.user_profile[@"industry"];
    businessLab.textColor=[UIColor grayColor];
    businessLab.font=[UIFont systemFontOfSize:15];
    [scrollView addSubview:businessLab];
    
    //划线
    UIView *line2=[[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(businessLab.frame)+10, self.view.frame.size.width, 0.5)];
    line2.backgroundColor=[UIColor colorWithRed:235/255.0 green:235/255.0 blue:241/255.0 alpha:1];
    [scrollView addSubview:line2];

    
    //性别
    UIImageView *sexImageView=[[UIImageView alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(line2.frame)+10, 30, 30)];
    sexImageView.image=[UIImage imageNamed:@"my_sex"];
    [scrollView addSubview:sexImageView];
    
    UILabel *sexLabName=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(sexImageView.frame)+5, sexImageView.frame.origin.y, 51, 30)];
    sexLabName.text=@"性 别:";
    sexLabName.textColor=[UIColor grayColor];
    sexLabName.font=[UIFont systemFontOfSize:17];
    [scrollView addSubview:sexLabName];
    UIImageView *manImageView=[[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(sexLabName.frame)+50, sexLabName.frame.origin.y+6, 18, 18)];
    manImageView.image=[UIImage imageNamed:@"myyuan_selected"];
    [scrollView addSubview:manImageView];
    UILabel *manLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(manImageView.frame)+5, manImageView.frame.origin.y, 18, 18)];
    manLab.text=@"男";
    manLab.font=[UIFont systemFontOfSize:15];
    manLab.textColor=[UIColor grayColor];
    [scrollView addSubview:manLab];
    
    //女
    UIImageView *womanImageView=[[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(manLab.frame)+20, sexLabName.frame.origin.y+6, 18, 18)];
    womanImageView.image=[UIImage imageNamed:@"myyuan_normal"];
    [scrollView addSubview:womanImageView];
    UILabel *womanLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(womanImageView.frame)+5, womanImageView.frame.origin.y, 18, 18)];
    womanLab.text=@"女";
    womanLab.font=[UIFont systemFontOfSize:15];
    womanLab.textColor=[UIColor grayColor];
    [scrollView addSubview:womanLab];
    
    NSInteger sex;
    if ([_userModel.user_profile[@"sex"] isKindOfClass:[NSNull class]]) {
        sex=0;
    }else{
        sex=[_userModel.user_profile[@"sex"]integerValue];
    }
    if (sex==0) {
        manImageView.image=[UIImage imageNamed:@"myyuan_selected"];
        womanImageView.image=[UIImage imageNamed:@"myyuan_normal"];
    }else{
        manImageView.image=[UIImage imageNamed:@"myyuan_normal"];
        womanImageView.image=[UIImage imageNamed:@"myyuan_selected"];
    }
    
    
    
    //划线
    UIView *line3=[[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(sexLabName.frame)+10, self.view.frame.size.width, 0.5)];
    line3.backgroundColor=[UIColor colorWithRed:235/255.0 green:235/255.0 blue:241/255.0 alpha:1];
    [scrollView addSubview:line3];
    //年龄
    UIImageView *ageImageView=[[UIImageView alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(line3.frame)+10, 30, 30)];
    ageImageView.image=[UIImage imageNamed:@"my_age"];
    [scrollView addSubview:ageImageView];
    
    UILabel *ageLabName=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(ageImageView.frame)+5, ageImageView.frame.origin.y, 51, 30)];
    ageLabName.text=@"年 龄:";
    ageLabName.textColor=[UIColor grayColor];
    ageLabName.font=[UIFont systemFontOfSize:17];
    [scrollView addSubview:ageLabName];
    
    UILabel *ageLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(ageLabName.frame)+5, ageImageView.frame.origin.y, self.view.frame.size.width-(CGRectGetMaxX(ageLabName.frame)+5), 30)];
    ageLab.text=[NSString stringWithFormat:@"%@",_userModel.user_profile[@"age"]];
    ageLab.textColor=[UIColor grayColor];
    ageLab.font=[UIFont systemFontOfSize:15];
    [scrollView addSubview:ageLab];

    //划线
    UIView *line4=[[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(ageLabName.frame)+10, self.view.frame.size.width, 0.5)];
    line4.backgroundColor=[UIColor colorWithRed:235/255.0 green:235/255.0 blue:241/255.0 alpha:1];
    [scrollView addSubview:line4];
    //手机号码
    UIImageView *telephoneImageView=[[UIImageView alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(line4.frame)+10, 30, 30)];
    telephoneImageView.image=[UIImage imageNamed:@"my_telephone-1"];
    [scrollView addSubview:telephoneImageView];
    
    UILabel *telephoneLabName=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(telephoneImageView.frame)+5, telephoneImageView.frame.origin.y, 86, 30)];
    telephoneLabName.text=@"手机号码:";
    telephoneLabName.textColor=[UIColor grayColor];
    telephoneLabName.font=[UIFont systemFontOfSize:17];
    [scrollView addSubview:telephoneLabName];
    
    UILabel *telephoneLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(telephoneLabName.frame)+5, telephoneImageView.frame.origin.y, self.view.frame.size.width-(CGRectGetMaxX(telephoneLabName.frame)+5), 30)];
    telephoneLab.text=_userModel.user_profile[@"phone"];
    NSLog(@"手机号码===========%@",_userModel.user_profile[@"phone"]);
    telephoneLab.textColor=[UIColor grayColor];
    telephoneLab.font=[UIFont systemFontOfSize:15];
    [scrollView addSubview:telephoneLab];
    
    //划线
    UIView *line5=[[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(telephoneLabName.frame)+10, self.view.frame.size.width, 0.5)];
    line5.backgroundColor=[UIColor colorWithRed:235/255.0 green:235/255.0 blue:241/255.0 alpha:1];;
    [scrollView addSubview:line5];
    
    
    //计算行
    NSInteger hang=[self calculatingHang:_biaoqianArray.count];
    CGFloat height1;
    if (hang<=1) {
        height1=40;
    }else{
        height1=55;
    }
    //标签
    UIImageView *biaoqianImageView=[[UIImageView alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(line5.frame)+5+(height1-30)/2.0, 30, 30)];
    biaoqianImageView.image=[UIImage imageNamed:@"my_biaoqian"];
    [scrollView addSubview:biaoqianImageView];
    _biaoqianImageView=biaoqianImageView;
    
    
    UILabel *biaoqianLabName=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(biaoqianImageView.frame)+5, biaoqianImageView.frame.origin.y, 51, 30)];
    biaoqianLabName.text=@"标 签:";
    biaoqianLabName.textColor=[UIColor grayColor];
    biaoqianLabName.font=[UIFont systemFontOfSize:17];
    [scrollView addSubview:biaoqianLabName];
    _biaoqianLabName=biaoqianLabName;
    
    
    
    [self makeBiaoQianView:biaoqianLabName andImageView:line5 andScrollView:scrollView];
//    for (int i=0; i<_biaoqianArray.count; i++) {
//        UILabel *biaoqianLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(biaoqianLabName.frame)+5+((self.view.frame.size.width-40-(CGRectGetMaxX(biaoqianLabName.frame)+5)-10)/2.0+10)*i, biaoqianImageView.frame.origin.y+5, (self.view.frame.size.width-40-(CGRectGetMaxX(biaoqianLabName.frame)+5)-10)/2.0, 20)];
//        biaoqianLab.text=_biaoqianArray[i];
//        biaoqianLab.tag=i+1;
//        biaoqianLab.textColor=[UIColor colorWithRed:87/255.0 green:187/255.0 blue:215/255.0 alpha:1];
//        biaoqianLab.font=[UIFont systemFontOfSize:12];
//        biaoqianLab.layer.borderColor=[UIColor colorWithRed:87/255.0 green:187/255.0 blue:215/255.0 alpha:1].CGColor;
//        biaoqianLab.layer.borderWidth=1.5;
//        biaoqianLab.layer.cornerRadius=4.0;
//        biaoqianLab.textAlignment=NSTextAlignmentCenter;
//        [scrollView addSubview:biaoqianLab];
//    }
//    //更多标签
//    UIButton *moreBiaoQianBtn=[UIButton buttonWithType:UIButtonTypeCustom];
//    moreBiaoQianBtn.frame=CGRectMake(self.view.frame.size.width-40, biaoqianImageView.frame.origin.y+5, 20, 20);
//    [moreBiaoQianBtn setBackgroundImage:[UIImage imageNamed:@"app_right"] forState:UIControlStateNormal];
//    [moreBiaoQianBtn addTarget:self action:@selector(moreBiaoQianBtnClick:) forControlEvents:UIControlEventTouchUpInside];
//    [scrollView addSubview:moreBiaoQianBtn];
    
    //划线
    UIView *line6=[[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(line5.frame)+height1+10, self.view.frame.size.width, 0.5)];
    line6.backgroundColor=[UIColor colorWithRed:235/255.0 green:235/255.0 blue:241/255.0 alpha:1];
    [scrollView addSubview:line6];
    
    
    //比例图
    UIImageView *scaleImageView=[[UIImageView alloc]initWithFrame:CGRectMake(30, CGRectGetMaxY(line6.frame)+15, 60, 60)];
    scaleImageView.image=[UIImage imageNamed:@"666666-9"];
    [scrollView addSubview:scaleImageView];
    
    //已完成15%
    UILabel *scaleLab1=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(scaleImageView.frame)+10, scaleImageView.frame.origin.y, 100, scaleImageView.frame.size.height/3.0)];
    scaleLab1.text=@"已完成30%";
    scaleLab1.textColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1];
    scaleLab1.font=[UIFont systemFontOfSize:15];
    [scrollView addSubview:scaleLab1];
    if (_personalMessageState==2) {
        scaleImageView.image=[UIImage imageNamed:@"scale-0"];
        scaleLab1.text=@"已完成0%";
    }else if (_personalMessageState==3){
        scaleImageView.image=[UIImage imageNamed:@"scale-15"];
        scaleLab1.text=@"已完成15%";
    }else if (_personalMessageState==4){
        scaleImageView.image=[UIImage imageNamed:@"scale-30"];
        scaleLab1.text=@"已完成30%";
    }else if (_personalMessageState==5){
        scaleImageView.image=[UIImage imageNamed:@"scale-50"];
        scaleLab1.text=@"已完成50%";
    }else if (_personalMessageState==6){
        scaleImageView.image=[UIImage imageNamed:@"scale-70"];
        scaleLab1.text=@"已完成70%";
    }else if (_personalMessageState==7){
        scaleImageView.image=[UIImage imageNamed:@"scale-90"];
        scaleLab1.text=@"已完成90%";
    }else if (_personalMessageState==8){
        scaleImageView.image=[UIImage imageNamed:@"scale-100"];
        scaleLab1.text=@"已完成100%";
    }
    
    
    
    
    
    
    
    //完善资料 可奖获奖励
    UILabel *awardLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(scaleImageView.frame)+10, CGRectGetMaxY(scaleLab1.frame), self.view.frame.size.width-(CGRectGetMaxX(scaleImageView.frame)+10), scaleImageView.frame.size.height/3.0)];
    awardLab.text=@"完善全部资料 可获奖励";
    awardLab.textColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1];
    awardLab.font=[UIFont systemFontOfSize:15];
    [scrollView addSubview:awardLab];
    
    //50分
    UILabel *scoreLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(scaleImageView.frame)+10, CGRectGetMaxY(awardLab.frame), 50, scaleImageView.frame.size.height/3.0)];
    scoreLab.text=@"10分";
    scoreLab.textColor=[UIColor whiteColor];
    scoreLab.font=[UIFont systemFontOfSize:15];
    scoreLab.backgroundColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1];
    scoreLab.textAlignment=NSTextAlignmentCenter;
    [scrollView addSubview:scoreLab];
    
    //修改基本信息
    UIButton *changeMessageBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    changeMessageBtn.frame=CGRectMake(20, CGRectGetMaxY(scoreLab.frame)+35, (self.view.frame.size.width-20*3)/2.0, 40);
    changeMessageBtn.layer.borderColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1].CGColor;
    changeMessageBtn.layer.cornerRadius=3.0;
    changeMessageBtn.layer.borderWidth=5.0;
    [changeMessageBtn setTitle:@"修改基本信息" forState:UIControlStateNormal];
    changeMessageBtn.titleLabel.font=[UIFont systemFontOfSize:20];
    changeMessageBtn.backgroundColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1];
    [changeMessageBtn addTarget:self action:@selector(changeMessageBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [scrollView addSubview:changeMessageBtn];
    //修改登录密码
    UIButton *changePasswordBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    changePasswordBtn.frame=CGRectMake(CGRectGetMaxX(changeMessageBtn.frame)+20, CGRectGetMaxY(scoreLab.frame)+35, (self.view.frame.size.width-20*3)/2.0, 40);
    changePasswordBtn.layer.borderColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1].CGColor;
    changePasswordBtn.layer.cornerRadius=3.0;
    changePasswordBtn.layer.borderWidth=5.0;
    [changePasswordBtn setTitle:@"修改登录密码" forState:UIControlStateNormal];
    changePasswordBtn.titleLabel.font=[UIFont systemFontOfSize:20];
    changePasswordBtn.backgroundColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1];
    [changePasswordBtn addTarget:self action:@selector(changePasswordBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [scrollView addSubview:changePasswordBtn];
    scrollView.contentSize=CGSizeMake(self.view.frame.size.width, CGRectGetMaxY(changePasswordBtn.frame)+30);
    [self.view addSubview:scrollView];
    
    _name=name;
    _personalName=personalName;
    _cityLab=cityLab;
    _businessLab=businessLab;
    _womanImageView=womanImageView;
    _manImageView=manImageView;
    _ageLab=ageLab;
    _telephoneLab=telephoneLab;
    
}


//创建标签
-(void)makeBiaoQianView:(UILabel *)biaoqianLabName andImageView:(UIView *)biaoqianImageView andScrollView:(UIScrollView *)scrollView
{
    CGFloat lab_w=(self.view.frame.size.width-10-(CGRectGetMaxX(biaoqianLabName.frame)+5)-10*2-10)/3.0;
    CGFloat lab_h=20;
    NSInteger hang=[self calculatingHang:_biaoqianArray.count];
    CGFloat lab_y;
    if (hang<=1) {
        lab_y=CGRectGetMaxY(biaoqianImageView.frame)+(40-20)/2.0;
    }else{
        lab_y=CGRectGetMaxY(biaoqianImageView.frame)+5;
    }
    for (int i=0; i<hang; i++) {
        for (int j=0; j<3; j++) {
            if (i*3+j<_biaoqianArray.count) {
                UILabel *biaoqianLab=[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(biaoqianLabName.frame)+5+(lab_w+10)*j, lab_y+(5+lab_h)*i+5, lab_w, lab_h)];
                biaoqianLab.text=_biaoqianArray[i*3+j][@"name"];
                biaoqianLab.tag=i*3+j+1;
                biaoqianLab.textColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1];
                biaoqianLab.font=[UIFont systemFontOfSize:14];
                biaoqianLab.layer.borderColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1].CGColor;
                biaoqianLab.layer.borderWidth=1.5;
                biaoqianLab.layer.cornerRadius=4.0;
                biaoqianLab.textAlignment=NSTextAlignmentCenter;
                [scrollView addSubview:biaoqianLab];
            }
        }
       
    }

}
//修改基本信息
-(void)changeMessageBtnClick:(UIButton *)sender
{
    ChangeBaseMessageViewController *vc=[[ChangeBaseMessageViewController alloc]init];
    vc.dataDic=[NSDictionary dictionaryWithDictionary:_dataDic];
    vc.systemArray=[NSArray arrayWithArray:_systemArray];
    [self.navigationController pushViewController:vc animated:YES];
}
//修改登录密码
-(void)changePasswordBtnClick:(UIButton *)sender
{
    ChangeLoginPasswordViewController *vc=[[ChangeLoginPasswordViewController alloc]init];
    self.navigationController.navigationBar.hidden=NO;
    [self.navigationController pushViewController:vc animated:YES];
}
//返回上一页
-(void)backBtnClick:(UIButton *)sender
{
    self.tabBarController.tabBar.hidden=NO;
    self.navigationController.navigationBar.hidden=YES;
    [self.navigationController popViewControllerAnimated:YES];
}
//更多标签
-(void)moreBiaoQianBtnClick:(UIButton *)sender
{
//    MyBiaoQianViewController *vc=[[MyBiaoQianViewController alloc]init];
//    vc.returnData=^(NSArray *arr){
//        for (int i=0; i<_biaoqianArray.count; i++) {
//            UILabel *lab=[_myScrollView viewWithTag:i+1];
//            NSLog(@"====================%@",lab.text);
//            [lab removeFromSuperview];
//        }
//        _biaoqianArray=[NSArray arrayWithArray:arr];
//        [self makeBiaoQianView:_biaoqianLabName andImageView:_biaoqianImageView];
//        
//    };
//    [self.navigationController pushViewController:vc animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
//计算行
-(NSInteger)calculatingHang:(NSInteger)number
{
    NSInteger hang;
    if (number%3==0) {
        hang=number/3;
    }else{
        hang=number/3+1;
    }
    return hang;
}

//获取用户信息
-(void)getUserInfo
{
    AFHTTPRequestOperationManager * manager=[AFHTTPRequestOperationManager manager];
    manager.requestSerializer=[AFHTTPRequestSerializer serializer];
    manager.responseSerializer=[AFHTTPResponseSerializer serializer];
    
    NSUserDefaults *user=[NSUserDefaults standardUserDefaults];
    NSString *token= [user objectForKey:@"token"];
    
    [self.view isLoading:YES];
    [manager GET:[NSString stringWithFormat:@"%@%@",UserInfo,token] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        [self.view isLoading:NO];
        self.navigationController.navigationBar.hidden=YES;
        NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        NSLog(@"userInfo===%@",dic);
        if (dic) {
            _dataDic=[NSDictionary dictionaryWithDictionary:dic];
            dispatch_async(dispatch_get_main_queue(), ^{
                [self initData];
                [self createUI];
            });
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [self.view isLoading:NO];
        NSLog(@"%@",error.localizedDescription);
    }];
    
    [self getSystemBiaoQian];
}

-(void)getSystemBiaoQian
{
    AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManager manager];
    manager.requestSerializer=[AFHTTPRequestSerializer serializer];
    manager.responseSerializer=[AFHTTPResponseSerializer serializer];
    NSUserDefaults *user=[NSUserDefaults standardUserDefaults];
    NSString *token=[user objectForKey:@"token"];
    
    [manager GET:[NSString stringWithFormat:AllUserBiaoQian,token] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSArray *dic=[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        NSLog(@"所有系统标签===============%@",dic);
        _systemArray=[NSArray arrayWithArray:dic];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"%@",error.localizedDescription);
    }];
}


-(void)calculatenumber
{
    _personalMessageState=2;
    NSString *name=_userModel.userName;
    
    NSString *personalName=_userModel.user_profile[@"signatures"];
    
    NSString *city=_userModel.user_profile[@"province"];
    
    NSString *job=_userModel.user_profile[@"industry"];
    
    NSString *phone=_userModel.user_profile[@"phone"];
    
    NSLog(@"========%@===%@===%@",name,personalName,city);
    
    if ([_userModel.userName isKindOfClass:[NSNull class]]) {
        
    }else{
        if (name.length>0) {
            _personalMessageState+=1;
        }
    }
    
    if ([_userModel.user_profile[@"signatures"] isKindOfClass:[NSNull class]]) {
        
    }else{
        if (personalName.length>0) {
            _personalMessageState+=1;
        }
    }
    
    if ([_userModel.user_profile[@"province"] isKindOfClass:[NSNull class]]) {
        
    }else{
        if (city.length>0) {
            _personalMessageState+=1;
        }
    }
    
    if ([_userModel.user_profile[@"industry"] isKindOfClass:[NSNull class]]) {
        
    }else{
        if (job.length>0) {
            _personalMessageState+=1;
        }
    }
    
    if ([_userModel.user_profile[@"age"] isKindOfClass:[NSNull class]]) {
        
    }else{
        if (_userModel.user_profile[@"age"]) {
            _personalMessageState+=1;
        }
    }
    
    if ([_userModel.user_profile[@"phone"] isKindOfClass:[NSNull class]]) {
        
    }else{
        if (phone.length>0) {
            _personalMessageState+=1;
        }
    }
    NSLog(@"============%ld",_personalMessageState);
    
}

-(void)viewWillAppear:(BOOL)animated
{
    [self.navigationController.navigationBar setTranslucent:YES];
}
//
//-(void)viewWillDisappear:(BOOL)animated
//{
//    [self.navigationController.navigationBar setTranslucent:NO];
//}




/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
